import React, { useState } from 'react';
import './App.css'
import MessageBox from './views/slot/MessageBox';
import MyProvider from './views/context/MyProvider';
const App = () => {
  const [list, setList] = useState([{ id: 1, msg: '楼主', user: 'wqw', time: '2023-06-30' }])

  const addMsg = (value) => {
    let msgObj = { id: list.length + 1, msg: value, user: 'wqw', time: new Date().toLocaleDateString() }
    setList([...list, msgObj])
  }
  return (
    <div className='msg-box'>
      {/* 提高数据 */}
      <MyProvider list={list} addMsg={addMsg}>
        <MessageBox>
          <h1>留言板案例</h1>
        </MessageBox>
      </MyProvider>

    </div>
  );
}

export default App;
